package com.chao.product.controller;

import lombok.SneakyThrows;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.locks.LockSupport;


@Component
public class TestRedis implements Runnable {


    @SneakyThrows
    @Override
    public void run() {
        for(;;){
            RedisTemplate redisTemplate = BeanContext.getApplication().getBean(RedisTemplate.class);
            Long l =  redisTemplate.opsForValue().decrement("lvchao1000");
            //System.out.println(l);
            if(l < 0){
                l = redisTemplate.opsForValue().increment("lvchao1000");
                //System.out.println(l+":"+ Thread.currentThread().getName() + "结束");
                return;
            }
        }
    }
}
